package 线程停止;

class mythred extends Thread {
    public void run() {
	long beginTime = System.currentTimeMillis();
	int count = 0;
	for (int i = 0; i < 50000000; i++) {

	    if (this.isInterrupted()) {
		System.out.println("当前线程中止");
	    }
	    count = count + (i + 1);
	}
	long endTime = System.currentTimeMillis();
	System.out.println("用时：" + (endTime - beginTime) + "毫秒！");
    }
}

public class Test1_51 {

    public static void main(String[] args) {
	// TODO Auto-generated method stub
	mythred thread = new mythred();
	thread.start();
	try {
	    Thread.sleep(10);
	} catch (InterruptedException e) {
	    // TODO Auto-generated catch block
	    e.printStackTrace();
	}
	thread.interrupt();

    }

}
